<template>

  <div>
    <el-upload
      action="https://www.mericama.com//api/admin/aliyun/upload"
      :on-remove="handleRemove"
      :before-upload="beforeUpload"
      :limit="1"
      :on-success="SuccessUpload"
      class="upload-demo"
      drag
    >
      <i class="el-icon-upload" />
      <div class="el-upload__text">{{ $t('prompt.clickVideo') }}</div>
      <div slot="tip" class="el-upload__tip">{{ $t('prompt.videoSize') }}</div>
    </el-upload>
  </div>
</template>

<script>
// import { UploadFile } from '@/api/user'
export default {
  data() {
    return {
      dialogImageUrl: '',
      dialogVisible: false,
      imgUrl: '',
      currentFileUid: null
    }
  },
  methods: {
    // file是点击删除的文件
    handleRemove(file) {
      //   将原来的文件给排除掉了 剩下的就是最新的数组了
      this.imgUrl = ''
    },
    // 上传成功回调
    SuccessUpload(response, file, fileList) {
      console.log(response)
      this.imgUrl = response.data.file
    },
    // // 做文件上传的检查了
    beforeUpload(file) {
      // 检查文件是否为img类型
      const types = ['image/jpeg', 'image/gif', 'image/bmp', 'image/png', 'image/jpg', 'video/mp4']
      if (!types.some(item => item === file.type)) {
        // 如果不存在
        this.$message.error(this.$t('prompt.Upload'))
        return false
      }
      //  检查大小
      const maxSize = 1000 * 1024 * 3024
      if (maxSize < file.size) {
        this.$message.error(this.$t('prompt.videoSize'))
        return false
      }
      this.currentFileUid = file.uid
      return true
    }
  }
}
</script>

  <style>
      .disabled .el-upload--picture-card{
          display: none;
      }
  </style>

